using System.IO;
using Framework;
using UnityEditor;
using UnityEngine;

public class CustomBuildCommandProcessor : BuildCommandProcessor
{
    public override void BuildBundlePrepare(BuildCommandContext context)
    {
        base.BuildBundlePrepare(context);
        if (string.IsNullOrEmpty(context.GetStringArg("PathExportBundle")))
        {
            var path = Path.GetFullPath(Application.dataPath + "/../output_bundle");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
    }
    public override void BuildBundleAfter(BuildCommandContext context)
    {
        base.BuildBundleAfter(context);
        if (string.IsNullOrEmpty(context.GetStringArg("PathExportBundle")))
        {
            var path = Path.GetFullPath(Application.dataPath + "/../output_project");
            path = Path.Combine(path, "unityLibrary/src/main/assets");
            if (!Directory.Exists(path))
            {
                return;
            }

        }
    }
    public override void ExportProjectPrepare(BuildCommandContext context)
    {
        base.ExportProjectPrepare(context);
        if (string.IsNullOrEmpty(context.GetStringArg("PathExportProject")))
        {
            var path = Path.GetFullPath(Application.dataPath + "/../output_project");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }

    }
    public override void ExportProjectBefore(BuildCommandContext context)
    {
        base.ExportProjectBefore(context);
        if (context.BuildTarget == UnityEditor.BuildTarget.StandaloneWindows)
        {
            context.SetLocationName(PlayerSettings.productName + ".exe");
        }
    }
}